package com.hong.arithmetic.diff;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author: csh
 * @Date: 2022/4/14 22:59
 * @Description:
 */
public class DiffUtils {
    public static List<User> initList1= new ArrayList<>();
    public static List<User> initList2 = new ArrayList<>();

    public static void main(String[] args) {


        for (int i = 0; i < 10; i++) {
            initList1.add(new User("用户"+i,i,"小"+i));
            if(i!=0){
                initList2.add(new User("用户"+i,i,"小"+i));
            }
        }

        //initList1中去除initList2相同的数据
        System.out.println(initList1.size());
        initList1.removeAll(initList2);
        System.out.println( initList1.size());
        List collect = initList1.stream().filter(item -> initList2.stream().noneMatch(e -> Objects.equals(item.getUserName(), e.getUserName()))).collect(Collectors.toList());
        System.out.println(collect.size());
        //        studentList = studentList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Student :: getAge))), ArrayList::new));

    }
}
